using DealerPlatform.Core.Consts;
using DealerPlatform.Service.CustomerApp;
using DealerPlatform.Service.CustomerApp.Dtos;
using DealerPlatform.Web.Filters;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace DealerPlatform.Web.Controllers;

[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[CtmAuthorizationFilter]
public class CustomerController(
    ICustomerService customerService) : BaseController
{
    [HttpGet("Invoice")]
    public async Task<List<InvoiceOfOrderConfirmDto>> Get()
    {
        var cno = HttpContext.Items[HttpContextItemKeyName.CUSTOMER_NO]?.ToString();
        return await customerService.GetInvoiceByUser(cno);
    }

    [HttpGet]
    public async Task<CustomerDto> GetCustomerDto()
    {
        var cno = HttpContext.Items[HttpContextItemKeyName.CUSTOMER_NO]?.ToString();
        return await customerService.GetCustomerDto(cno);
    }
}